<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Until</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Until <span class="ver">[AHK_L 59+]</span></h1>

<p>Applies a condition to the continuation of a Loop or For-loop.</p>

<pre class="Syntax">Loop {
    ...
} Until <i>Expression</i></pre>
<h3>Parameters</h3>
<dl>

  <dt>Expression</dt>
  <dd><p>Any valid <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

</dl>

<h3>Remarks</h3>
<p>The expression is evaluated once after each iteration, and is evaluated even if <a href="Continue.htm">continue</a> was used. If the expression evaluates to false (which is an empty string or the number 0), the loop continues; otherwise, the loop is broken and execution continues at the line following <i>Until</i>.</p>
<p>Loop Until is shorthand for the following:</p>
<pre>Loop {
    ...
    if (<i>Expression</i>)
        break
}</pre>
<p>However, Loop Until is often easier to understand and unlike the above, can be used with a single-line action. For example:</p>
<pre>Loop
    x *= 2
Until x > y</pre>
<p><i>Until</i> can be used with any Loop or For. For example:</p>
<pre>Loop, Read, %A_ScriptFullPath%
    lines .= A_LoopReadLine . "`n"
<b>Until</b> A_Index=5  <em>; Read the first five lines.</em>
MsgBox % lines
</pre>
<p>If <a href="../Variables.htm#Index">A_Index</a> is used in <i>Expression</i>, it contains the index of the iteration which has just finished.</p>

<h3>Related</h3>
<p><a href="Loop.htm">Loop</a>, <a href="While.htm">While-loop</a>, <a href="For.htm">For-loop</a>, <a href="Break.htm">Break</a>, <a href="Continue.htm">Continue</a>, <a href="Block.htm">Blocks</a>, <a href="LoopFile.htm">Files-and-folders loop</a>, <a href="LoopReg.htm">Registry loop</a>, <a href="LoopReadFile.htm">File-reading loop</a>, <a href="LoopParse.htm">Parsing loop</a>, <a href="IfExpression.htm">If (expression)</a></p>
